In [1]:
    
%env CLIENT bitrepository-client-1.9-RC1
!wget -Nq "https://sbforge.org/download/attachments/25395346/${CLIENT}.zip"
!unzip -quo ${CLIENT}.zip
%alias bitmag ${CLIENT}/bin/bitmag.sh %l
    
    Out[1]:
Upload a file with a known checksum for so we have something to test on
In [7]:
    
%env TESTFILE1 README.md
    
    
In [8]:
    
%bitmag put-file -c integrationtest1 -f $TESTFILE1 -i $TESTFILE1
    
    
In [9]:
    
!md5sum $TESTFILE1
    
    
In [10]:
    
%bitmag get-checksums -c integrationtest1 -i $TESTFILE1
    
    
The correct checksum should be returned by all the pillars.
In [12]:
    
import hmac
import hashlib
import base64
def getSaltedChecksum(file,saltHex,algorithm):
    #Note, the salt is a hex string
    salt = bytearray.fromhex(saltHex)
    digester = hmac.new(salt,None,algorithm)
    with open(file,'rb') as from_fh:
        while True:
            chunk = from_fh.read()
            if not chunk:
                break
            digester.update(chunk)
    return digester.hexdigest().lower()
file = os.environ.get('TESTFILE1')
print(getSaltedChecksum(file,saltHex='abcd',algorithm=hashlib.md5))
    
    
In [14]:
    
%bitmag get-checksums -c integrationtest1 -i $TESTFILE1 -R HMAC_MD5 -S 'abcd'
    
    
The correct salted checksum should be returned by all the pillars (except the ChecksumPillar).
Request the checksum of a file that does not exist in the collection.
In [16]:
    
%bitmag get-checksums -c integrationtest1 -i ThisFileDoesNotExist
    
    
No results should be returned.